package com.jarvis.hospital.adapter;

import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jarvis.hospital.R;
import com.jarvis.hospital.model.OpertionModel;

import java.util.List;

/**
 * Created by jarvis.liu on 9/12/2016.
 */
public class OperationAdapter extends BaseQuickAdapter<OpertionModel> {

    public OperationAdapter(int layoutResId, List<OpertionModel> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, OpertionModel opertionModel) {
        baseViewHolder
                .setText(R.id.tv_content, opertionModel.getTaskContent())
                .setText(R.id.tv_bed_number, opertionModel.getTaskPatientBedNumber())
                .setText(R.id.tv_patient_name, opertionModel.getTaskPatientName())
                .setText(R.id.tv_time, opertionModel.getTaskTimePlan())
                .setText(R.id.tv_medicine_name, opertionModel.getTaskMedicineName());
        TextView tv_name = baseViewHolder.getView(R.id.tv_status);
        LinearLayout lin_bg = baseViewHolder.getView(R.id.lin_bg);
        if("0".equals(opertionModel.getTaskTimeAct())){
            lin_bg.setBackground(mContext.getResources().getDrawable(R.drawable.app_list_corner_yellow));
            tv_name.setVisibility(View.GONE);
        }else if("-1".equals(opertionModel.getTaskTimeAct())){
            lin_bg.setBackground(mContext.getResources().getDrawable(R.drawable.app_list_corner_green));
            tv_name.setVisibility(View.VISIBLE);
            tv_name.setText("未抢任务");
        }else {
            lin_bg.setBackground(mContext.getResources().getDrawable(R.drawable.app_list_corner_blue));
            tv_name.setVisibility(View.VISIBLE);
            tv_name.setText("已处理");
        }

    }
}
